/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#ifndef MK_SIP_LISTENER_H
#define MK_SIP_LISTENER_H
#include "MkSocket/MkSocket.h"
#include "MkSipMessage.h"

typedef MkFunction<void(const CMkSipMessage& SipMessage)> SipMsgCompleteCallback;
class CMkSipServer;
class MkApi CMkSipListener
{
public:
    CMkSipListener(CMkSipServer* pParent);
    virtual ~CMkSipListener();

    const MkString& GetPublicHost() const { return m_PublicHost; }
    const Uint16& GetPublicPort() const { return m_PublicPort; }
    void SetPublicHost(const MkString& PublicHost) { m_PublicHost = PublicHost; }
    void SetPublicPort(const Uint16& PublicPort) { m_PublicPort = PublicPort; }
    const MkString& GetListenHost() const { return m_ListenHost; }
    const Uint16& GetListenPort() const { return m_ListenPort; }
    CMkSipServer* GetParent() { return m_pParent; }

    virtual Uint32 Start(const MkString& ListenHost, Uint16 ListenPort, const MkString& PublicHost, Uint16 PublicPort);
    virtual Uint32 SendSipMessage(const CMkSipMessage& SipMessage, const SipMsgCompleteCallback& Cb = nullptr, BOOL bResend = FALSE) = 0;
protected:
private:
    MkString                m_PublicHost;
    Uint16                  m_PublicPort;
    MkString                m_ListenHost;
    Uint16                  m_ListenPort;
    CMkSipServer*           m_pParent;
};


#endif